import axios from '@/libs/axios.js';
import baseUrl from './index';
let jsonHeaders = { 'content-type': 'application/json;charset=UTF-8' };
import qs from 'qs';
// 工程列表
export const projectList = (params) => {
    return axios({
        url: `${baseUrl}/referee/referee/contest`,
        method: 'get',
        headers: jsonHeaders,
        params: params
    });
};


// 审核人员列表
export const refereeList = (params) => {
    return axios({//GET /referee/getRefereeList
        url: `${baseUrl}/referee/referee/getRefereeList`,
        method: 'get',
        headers: jsonHeaders,
        params: params
    });
};
// 任务列表
export const taskList = (params) => {
    return axios({
        url: `${baseUrl}/referee/referee/tasks`,
        method: 'get',
        headers: jsonHeaders,
        params: params
    });
};
// 报告列表
export const reportList = (params) => {
    return axios({
        url: `${baseUrl}/referee/referee/reports`,
        method: 'get',
        headers: jsonHeaders,
        params: params,
        paramsSerializer: function(params) {
            return qs.stringify(params, { arrayFormat: 'repeat' });
        }
    });
};

// http://172.25.0.30:18769/referee/referee/statisticIndustry/ed124c8d-40ae-4927-b694-bb9b77d9d42e
export const reportStatisticIndustry = (id) => {// b0e21692-7eaf-45bc-9e25-77bb3bb3feb5
    //id = 'b0e21692-7eaf-45bc-9e25-77bb3bb3feb5'
    return axios({
        url: `${baseUrl}/referee/referee/statisticIndustry/${id}`,
        method: 'get',
        headers: jsonHeaders,
        paramsSerializer: function(params) {
            return qs.stringify(params, { arrayFormat: 'repeat' });
        }
    });
};


// 报告列表
export const reportFileData = (id) => {
    return axios({
        url: `${baseUrl}/referee/referee/reports/${id}`,
        method: 'get',
        headers: jsonHeaders
    });
};
// 审核日志列表
export const reportLog = params => {
    return axios({
        url: `${baseUrl}/referee/referee/log`,
        method: 'get',
        headers: jsonHeaders,
        params:params
    })
}
// 审核报告
export const reviewReport = (params) => {
    return axios({
        url: `${baseUrl}/referee/referee/approval`,
        method: 'post',
        data: params,
        headers: jsonHeaders
    });
};

/**
 * 打包下载指定护网演练的所有报告
 * @param {*} id
 * @returns
 */
export const downloadReports = (id, reportIds, fn) => {
    return axios({
        url: `${baseUrl}/referee/referee/downloadZip/${id}`,
        method: 'post',
        data: reportIds,
        headers: {
            'Content-Type': 'application/json; application/octet-stream'
        },
        responseType: 'blob',
        onDownloadProgress: fn,
        timeout: 0
    });
};

export const downloadReportsNew = (testName, params, fn) => {
    return axios({
        url: `${baseUrl}/referee/referee/newDownloadZip/${testName}`,
        method: 'get',
        params,
        paramsSerializer: function(params) {
            return qs.stringify(params, { arrayFormat: 'repeat' });
        },
        headers: {
            'Content-Type': 'application/json; application/octet-stream'
        },
        responseType: 'blob',
        onDownloadProgress: fn,
        timeout: 0
    });
};

export const downloadReportRecord = (sceneName, params, fn) => {
    return axios({
        url: `${baseUrl}/compete/scoring/newExportReport/${sceneName}`,
        method: 'get',
        params,
        paramsSerializer: function(params) {
            return qs.stringify(params, { arrayFormat: 'repeat' });
        },
        headers: {
            'Content-Type': 'application/json; application/octet-stream'
        },
        responseType: 'blob',
        onDownloadProgress: fn,
        timeout: 0
    });
};

//导出单位报告及统计信息
export const exportCompanyReports = (sceneId, sceneName, params, fn) => {
    return axios({
        url: `${baseUrl}/compete/scoring/newDownloadZip/${sceneId}/${sceneName}`,
        method: 'get',
        params: params,
        paramsSerializer: function(params) {
            return qs.stringify(params, { arrayFormat: 'repeat' });
        },
        headers: {
            'Content-Type': 'application/json; application/octet-stream'
        },
        responseType: 'blob',
        onDownloadProgress: fn,
        timeout: 0
    });
};

//导出所有报告及统计信息
export const exportAllCompanyReports = (sceneId, sceneName, type, fn) => {
    return axios({
        url: `${baseUrl}/compete/scoring/allZip/${sceneId}/${sceneName}/${type}`,
        method: 'get',
        params: {},
        paramsSerializer: function(params) {
            return qs.stringify(params, { arrayFormat: 'repeat' });
        },
        headers: jsonHeaders
        // headers: {
        //   'Content-Type': 'application/json; application/octet-stream'
        // },
        // responseType: 'blob',
        // onDownloadProgress: fn,
        // timeout: 0
    });
};
//导出靶标信息
export const downloadTarget = (projectId, sceneName, fn) => {
    return axios({
        url: `${baseUrl}/compete/topoTarget/exportTarget/${projectId}/${sceneName}`,
        method: 'get',
        params: {},
        headers: {
            'Content-Type': 'application/json; application/octet-stream'
        },
        responseType: 'blob',
        onDownloadProgress: fn,
        timeout: 0
    });
};

// 分页获取加减分管理的数据
export const getScoreManageList = (params) => {
    return axios({
        url: `${baseUrl}/referee/referee/tasks/rate`,
        method: 'get',
        params,
        headers: jsonHeaders
    });
};

// 添加加减分
export const addScoreManage = (params) => {
    return axios({
        url: `${baseUrl}/referee/referee/tasks/rate`,
        method: 'post',
        data: params,
        headers: jsonHeaders
    });
};

// 修改加减分
export const updateScoreManage = (params) => {
    return axios({
        url: `${baseUrl}/referee/referee/tasks/rate`,
        method: 'put',
        data: params,
        headers: jsonHeaders
    });
};

// 删除加减分
export const deleteScoreManage = (id) => {
    return axios({
        url: `${baseUrl}/referee/referee/tasks/rate/${id}`,
        method: 'delete',
        headers: jsonHeaders
    });
};

//查询申报的目标报告是否都是驳回状态
export const getTargetReportsStatus = (sceneId, targetId) => {
    return axios({
        url: `${baseUrl}/referee/referee/reports/${sceneId}/${targetId}`,
        method: 'get',
        params: {},
        headers: jsonHeaders
    });
};

//修改靶标的状态为驳回状态
export const rejectTargetReports = (sceneId, targetId) => {
    return axios({
        url: `${baseUrl}/referee/referee/reports/${sceneId}/${targetId}`,
        method: 'post',
        headers: jsonHeaders
    });
};

// 获取告警信息
export const getAlarmList = (params) => {
    return axios({
        url: `${baseUrl}/compete/alarm/page`,
        method: 'get',
        params,
        headers: jsonHeaders
    });
};

//审核日志
export const getRefereeAuditlog = (params) => {
    return axios({
        url: `${baseUrl}/referee/referee/log`,
        method: 'get',
        params,
        headers: jsonHeaders
    });
};

// 高危报备列表-裁判
export const targetReportList = (sceneId,params) =>{
    return axios({
        url: `${baseUrl}/compete/targetDeclare/page/${sceneId}`,
        method: 'get',
        headers: jsonHeaders,
        params
    })
}

// 高危报备列表审核
export const targetExamine = (id, checkStatus, params) =>{
    return axios({
        url: `${baseUrl}/compete/targetDeclare/${id}/${checkStatus}`,
        method: 'put',
        headers: jsonHeaders,
        data: params
    })
}

// 目标列表
export const targetNameList = projectId =>{
    return axios({
        url: `${baseUrl}/compete/targetDeclare/company/${projectId}`,
        method: 'get',
        headers: jsonHeaders,
    })
}

//裁判漏洞统计情况
export const vulnerabilityStats = (params) => {
    return axios({
        url: `${baseUrl}/testplatform/stats/ns/smartScreen/vul/page`,
        method: 'get',
        params,
        headers: jsonHeaders
    });
};

//推送漏洞
export const pushVulnerability = (vulId,params) => {
    return axios({
        url: `${baseUrl}/testplatform/stats/ns/smartScreen/vul/${vulId}/push`,
        method: 'put',
        params,
        headers: jsonHeaders
    });
};